package com.wenlin.myproduction.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.wenlin.myproduction.R;
import com.wenlin.myproduction.base.BaseActivity;
import com.wenlin.myproduction.base.BaseSwipeActivity;
import com.wenlin.myproduction.util.ValCommon;
import com.wenlin.myproduction.widget.FrontAndBackView;

import java.util.Random;

import butterknife.BindView;
import butterknife.OnClick;

public class FrontAndBackViewActivity extends BaseSwipeActivity {

    @BindView(R.id.iv_ad)
    ImageView iv;
    @BindView(R.id.iv_gift)
    ImageView ivGift;

    private boolean done;

    @Override
    public int getContentView() {
        return R.layout.activity_front_and_back_view;
    }

    public static void start(BaseActivity activity) {
        Intent intent = new Intent(activity, FrontAndBackViewActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle(ValCommon.FRONT_AND_BACK_VIEW);
    }

    @OnClick({R.id.iv_ad})
    void click(View view) {
        switch (view.getId()) {
            case R.id.iv_ad:
                if (done) return;
                FrontAndBackView frontAndBackView = new FrontAndBackView(this, iv, ivGift);
                frontAndBackView.setListener(() -> done = true);
                String[] rewards = {"http://resimg.iqeq.cn/myenglish/res/2021/2/1/sn8K8YD5KkHbQQ4GDGekmT4MtaHsHP4J.png",
                        "http://resimg.iqeq.cn/myenglish/res/2021/2/1/4FAxa3bpy2BtWZMsX7KZ5Yhw7jnYWjEw.png",
                        "http://resimg.iqeq.cn/myenglish/res/2021/2/1/KMAPB2wSZeESeRcaMDswQM8CsbXjmXSN.png",
                        "http://resimg.iqeq.cn/myenglish/res/2021/2/1/xhAwjZWQk4KYdrWMW3Bnr7QrnhkApdJZ.png",
                        "http://resimg.iqeq.cn/myenglish/res/2021/2/1/JAPPjfKR5xTcYEWnHrybDHNrXpprKzEH.png",
                        "http://resimg.iqeq.cn/myenglish/res/2021/2/1/m86AHt4yH5zcGcAdc6p2ZE7tp2jM2FFz.png",
                        "http://resimg.iqeq.cn/myenglish/res/2021/2/1/cSSp3yY3C7fHNzzMHnYKPRMtXG5NiM26.png"};
                Random random = new Random();
                frontAndBackView.toggle(rewards[random.nextInt(rewards.length)]);
                break;
            default:
        }
    }
}
